<?php
class News
{
	public function construct()
	{
		
	}
	
	public function index()
	{
		CommonFunc::loadFile(SMARTYLIBS . "Smarty.class.php");
		CommonFunc::loadFile('model/News.php');		
		$smarty = new Smarty();
		$modNews = new ModelNews();
		$news_arr = $modNews->listNews();
		$smarty->assign("title", "News Management");	
		$smarty->assign("news_arr", $news_arr);
		$smarty->display('news/index.tpl');
	}

	public function addNews()
	{
		CommonFunc::loadFile(SMARTYLIBS . "Smarty.class.php");
		CommonFunc::loadFile(ADAPTOR . "/EditorFCK.php");
		CommonFunc::loadFile('model/News.php');		
		$smarty = new Smarty();
		$editorFCKHelper = new EditorFCKHelper();
		$smarty->assign('objeditorFCK', $editorFCKHelper);
		$smarty->assign("title", "Add News");	
		$smarty->display(ADMINTPL . "news/addnews.tpl");
	}
	
	public function editNews()
	{
		CommonFunc::loadFile(SMARTYLIBS . "Smarty.class.php");
		CommonFunc::loadFile(ADAPTOR . "/EditorFCK.php");
		CommonFunc::loadFile('model/News.php');		
		$smarty = new Smarty();
		$editorFCKHelper = new EditorFCKHelper();
		$modNews = new ModelNews();
		$request = CommonFunc::getRequest();
		$news_id = $request['param1'];
		$news_arr = $modNews->getNewsById($news_id);		
		$smarty->assign('objeditorFCK', $editorFCKHelper);
		$smarty->assign("title", "Edit News");	
		$smarty->assign("news_id", $news_id);	
		$smarty->assign('news_arr', $news_arr);
		$smarty->display(ADMINTPL . "news/editnews.tpl");
	}
	
	public function saveNews()
	{
		CommonFunc::loadFile(SMARTYLIBS . "Smarty.class.php");
		CommonFunc::loadFile('model/News.php');
		$smarty = new Smarty();
		$modNews = new ModelNews();
		$request = CommonFunc::getRequest();
		$modNews->saveNews($request); 
	}
}	
?>